Skip to content

Convert single-value enums to const and add URI format constraints#8145

Closed
Copilot wants to merge 2 commits intomainfrom
copilot/convert-enums-to-const
Closed

Convert single-value enums to const and add URI format constraints#8145
Copilot wants to merge 2 commits intomainfrom
copilot/convert-enums-to-const

Conversation

Copy link
Contributor

Copilot AI commented Dec 30, 2025

Addresses schema audit issues #5 and #6: 17 instances of single-value enums were using "enum": ["value"] instead of the JSON Schema best practice "const": "value", and no format constraints were applied to URI fields.

Changes

Single-value enum → const conversions (17 instances)

  • mcp_config_schema.json: HTTP/stdio type constraints (4)
  • included_file_schema.json: HTTP type, network defaults, firewall disable, stdio validation (5)
  • main_workflow_schema.json: Event types (completed, checks_requested, started), permissions (read), network/firewall settings, roles (all) (8)
// Before
"type": {
  "enum": ["stdio"]
}

// After
"type": {
  "const": "stdio"
}

URI format constraints (8 fields)

  • Added "format": "uri" to MCP server url and registry fields across all schemas
  • Excluded environment.url which accepts GitHub Actions expressions like ${{ steps.deploy.outputs.url }}

Test adjustments

  • Updated empty URL validation test to expect format error instead of minLength error, demonstrating improved validation specificity

Format validation now catches invalid URIs at schema validation time with clearer error messages.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/user
    • Triggering command: /usr/bin/gh gh api user --jq .login om/super-linter/--json (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login -nilfunc git /home/REDACTED/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.0.linux-amd64/bin/go k/gh-aw/gh-aw/.ggit 17 single-value rev-parse l/linux_amd64/as--show-toplevel go buil�� action.git action.git /usr/bin/git l ./cmd/gh-aw e/git-remote-htt/tmp/validate-js-2864696056.cjs git (http block)
    • Triggering command: /usr/bin/gh gh api user --jq .login action.git t /usr/bin/git l om/actions/downl-1 l/linux_amd64/vexterm-color git -C .git .git 0/x64/bin/node l om/actions/checkapi pkg/mod/golang.ouser k/gh-aw/gh-aw/gh--jq (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[plan] Convert single-value enums to const and add format constraints</issue_title>
<issue_description>## Objective

Improve schema quality by converting single-value enum arrays to const (JSON Schema best practice) and adding format constraints where appropriate.

Context

This addresses Issues #5 and #6 (Low priority) from the schema audit:

  • 10 instances use "enum": ["value"] instead of "const": "value"
  • Zero format constraints despite opportunities for stronger validation (email, uri, date-time, etc.)

These are minor refinements but improve schema correctness and validation strength.

Approach

Part 1: Convert Single-Value Enums

Find all instances of "enum": ["single-value"] and replace with "const": "single-value".

Expected pattern:

// Before
"type": {
  "enum": ["stdio"]
}

// After
"type": {
  "const": "stdio"
}

Part 2: Add Format Constraints

Identify fields that would benefit from format constraints:

  • URLs → "format": "uri"
  • Email addresses → "format": "email"
  • Date/time fields → "format": "date-time"
  • Relative references → "format": "uri-reference"

Note: Only add format constraints where validation makes sense. Don't add them just to have them.

Files to Modify

  • pkg/parser/schemas/main_workflow_schema.json
  • pkg/parser/schemas/included_file_schema.json
  • pkg/parser/schemas/mcp_config_schema.json

Implementation Steps

  1. Search for "enum": [ with single-element arrays
  2. Replace with "const": (10 expected instances)
  3. Review string fields for format constraint opportunities
  4. Add format constraints to URL, email, and date-time fields
  5. Test that validation behavior remains correct

Acceptance Criteria

  • All single-value enums converted to const
  • Format constraints added to appropriate string fields (URLs, dates, etc.)
  • Schema validation still passes
  • No breaking changes to validation behavior
  • Run make build and make test to verify everything compiles and tests pass

Estimated Effort

1-2 hours (includes careful validation testing)

AI generated by Plan Command for discussion #8130

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

- Converted 17 single-value enum instances to const per JSON Schema best practice:
  - mcp_config_schema.json: 4 instances (http, stdio type constraints)
  - included_file_schema.json: 5 instances (http, defaults, disable, stdio)
  - main_workflow_schema.json: 8 instances (completed, checks_requested, started, read, defaults, disable, all, http)

- Added format: uri constraints to appropriate string fields:
  - MCP server url fields (all 3 schemas)
  - MCP server registry fields (all 3 schemas)
  - HTTP mode MCP server url field (main schema)

- Updated test expectation for empty URL field to check format validation
- Excluded environment.url from format constraint (accepts GitHub expressions)

All unit tests passing. Ready for full test suite.

Co-authored-by: mnkiefer <8320933+mnkiefer@users.noreply.github.com>
Copilot AI changed the title [WIP] Convert single-value enums to const and add format constraints Convert single-value enums to const and add URI format constraints Dec 30, 2025
Copilot AI requested a review from mnkiefer December 30, 2025 02:54
@pelikhan pelikhan closed this Dec 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[plan] Convert single-value enums to const and add format constraints

3 participants